<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<link href="/static/css/default.css" rel="stylesheet" type="text/css">
<link href="/static/css/style/green.css" rel="stylesheet" type="text/css" id = 'link'>
</head>

<body style="overflow:hidden; padding:10px;">
	<form>
    <table class="formtable" style="width:580px;">
    
    <tbody>
    
    	<tr>
        <td class="tlabel">菜单名称</td>
        <td>
		<input type="text" class="forminput inputstyle1" id="textstr" value="{$info.textstr}">
		</td>
        </tr>
        
        <tr>
        <td class="tlabel">值</td>
        <td>
		<input type="text" class="forminput inputstyle1" id="valuestr" value="{$info.valuestr}">
		</td>
        </tr>
        
        <tr>
        <td class="tlabel">上级菜单</td>
        <td>
		 <select type="text" id="parentid"  class="select"  v-model="checked">
						     <option value="0">
								 无
								</option>
                                <option v-for="item in list" :value='item.id'>
								 {{item.textstr}}
								</option>
                            </select>
		</td>
        </tr>
        
        <tr>        
        <td class="tlabel">图标</td>
        <td>
		<input type="text" id="imgurlsrc" class="forminput inputstyle1" value="{$info.imgurlsrc}">
		</td>
        </tr>
        
        <tr>
        <td class="tlabel">地址</td>
        <td><input type="text" id="nvaurl"  class="forminput inputstyle1" value="{$info.nvaurl}"></td>
        </tr>
        
        <tr>
        <td class="tlabel">排序</td>
        <td><input type="text" id="seq" class="forminput inputstyle1" value="{$info.seq}"></td>
        </tr>
        
      
        <tr>
        <td class="tlabel">备注</td>
        <td><input type="text" id="desc"  class="forminput inputstyle1" value="{$info.desc}"></td>
        </tr>
                
         <tr>
        <td class="tlabel">状态</td>
        <td>
		<select type="text" id="state" class="select"  required="required">
		
		{if condition="$info.state eq 1"} 
			<option value="1" selected="selected"> 正常 </option>
								<option value="-1"> 禁用 </option>
{elseif condition="$info.state eq -1"/}
<option value="1"> 正常 </option>
								<option value="-1" selected="selected"> 禁用 </option>
{else /} 
<option value="1"> 正常 </option>
								<option value="-1"> 禁用 </option>
{/if}

                               
                            </select>
		</td>
        </tr>
                
        
        
    </tbody>
    
    </table>
    
    <div class="formbtn">
    <input type="button" value="保存"  class="btnsave">
    <input type="button" value="取消"  class="btncancel">
    </div>
    <input type="hidden" id="id" value="{$info.id}" />
</form>


</body>
	<script type="text/javascript" src="/static/js/jquery.js"></script>
    <script type="text/javascript" src="/static/js/common.js"></script>
	<script type="text/javascript" src="/static/js/vue2.js"></script>
	<script src="/static/js/layer/layer.js"></script>
<script>
var parentid ="{$info.parentid}";
    var menu = new Vue({
        el: '#parentid',
        data: {
			checked:parentid,
            list: []
        },
        methods: {
            getdata: function () {
                var _self = this;//保存this的指向
                $.get('/Super/Menu/GetMenuList', function (data) {
                    _self.list = data;
                });
            }

        },
        created: function () {  //初始化事件里边去调用查询方法
            this.getdata();
        }
    });
	
	$(function(){
		$(".btnsave").click(function(){
			 var id = $("#id").val();
			var textstr = $("#textstr").val();
			var imgurlsrc = $("#imgurlsrc").val();
			var valuestr = $("#valuestr").val();
			var nvaurl = $("#nvaurl").val();
			var parentid = $("#parentid").val();
			var seq = $("#seq").val();
			var desc = $("#desc").val();
			var state = $("#state").val();

			$.post("/Super/Menu/Add", { "id": id, "textstr": textstr, "imgurlsrc": imgurlsrc, "valuestr": valuestr,
			"nvaurl": nvaurl,"parentid":parentid,"seq":seq,"state":state,"desc":desc }, function (data) {
				if (data.status == 200) {
					var index = parent.layer.getFrameIndex(window.name);
					window.parent.iframe.contentWindow.location.reload(true);
					console.log(window.parent.iframe);
					parent.layer.close(index);
				}else{
					layer.msg(data.msg);
				}
			});
		});
		$(".btncancel").click(function(){
			var index = parent.layer.getFrameIndex(window.name);
			parent.layer.close(index);
		});
	});
   

</script>
</html>
